<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-color.css">
        <link rel="stylesheet" href="css/appcan.icon.css">
        <link rel="stylesheet" href="css/appcan.control.css">
        <link rel="stylesheet" href="css/media.css"/>
        <link rel="stylesheet" href="css/base.css"/>
        <!--<link rel="stylesheet" href="css/IScroll.css"/>-->

    </head>
    <style type="text/css">
        .hide {
            overflow: hidden; /*自动隐藏文字*/
            text-overflow: ellipsis;/*文字隐藏后添加省略号*/
            white-space: nowrap;/*强制不换行*/
        }
        .bdr_b {
            border-bottom: 1px solid #C1C1C1;
        }
        .w-ch {
            background-color: white;
        }
    </style>
    <body class="um-vp" ontouchstart>
     <div id="page_0" class="up ub ub-ver" tabindex="0">
      <div id="content" style=""> 
      
        <ul id="context" style="height: 100%;border: 1px solid white;">
        
         
        </ul>
   
     </div>
    </div> 
  
    <script src="js/appcan.js"></script>
    <script src="js/appcan.control.js"></script>
    </body>
    
    <script type="text/javascript" charset="utf-8">
    
    var curpage = 1;
    var count;
    //设置是否弹动
    var bounce = true;
    appcan.ready(function(){
        
      $('#content').css('height',$('#page_0').css("height"));
  
     
      if(bounce){
       //初始化上拉加载下拉刷新
       pullToRefresh_loadMore(onPullToRefresh, onUpToLoadMore);   
      }else{
       appcan.window.disableBounce();
       return;
      }
      
        
   
    });
    
    
    
     /* 
     * @http : 请求的地址。
     * @titHeight ： 头部高度
     * @contents : 上一页面传递来的内容
     * @detailPage ： 列表项的点击方法  参数id contents数组里的对象的contentId属性
     * @queryContentByIdCallBack ： 请求成功后回调函数
     */
            
 
        
    var http = appcan.locStorage.getVal('htpp');
    var folderId = appcan.locStorage.getVal('selfId');
    var contents = JSON.parse(appcan.locStorage.getVal('dataContents'));
    //console.log(contents);
    var tpl = '';
    if (contents != '[]' && contents != null && contents != undefined && contents.length > 0) {
     
        contents.forEach(function (item) {
     
            tpl += '<li id="' + item.contentId +
                '" class="bdr_b" onclick="detailPage(this)"><p class="fs10 pl5 tx-l h30 lh30 hide">' + item.contentName +
                '</p></li>';
        });
     
        $('#context').html(tpl);
    } else {
        
        $('#context').html('<div style="padding-top: 1em; text-align:center;">暂时没有数据...</div>');
        bounce = false;
    
    }
     
    var http = appcan.locStorage.getVal('http');
    //console.log(http);
     
    function detailPage(self) {
        ////IC.talkingDataCount("部门通告","0010");
        //console.log($(self).text());
        appcan.locStorage.setVal('title2', $(self).text());
        $.ajax({
            url: http + 'queryContentById',
            type: 'get',
            dataType: 'json',
            data: {
                contentId: self.id
            },
            success: function (res) {
                var data = JSON.parse(res.queryContentById);
                // console.log(data);
     
                appcan.locStorage.setVal('detailInfoObj', res.queryContentById);
                queryContentByIdCallBack();
            },
            error: function (err) {
                console.log(err);
            }
        });
     
    }
     
    function queryContentByIdCallBack() {
        //////IC.talkingDataCount("部门通告","0010");
        appcan.window.open({
            name: 'BMTGqueryContentByIdDetailPage',
            dataType: 0,
            data: 'BMTGqueryContentByIdDetailPage.html',
            aniId: 5
        });
    }
 

 
      
//下拉刷新,上推加载     //
 
function pullToRefresh_loadMore(funcTop, funcBottom) {
 
    appcan.window.setBounce({
        bounceType: [0, 1], //弹动的类型,如果为多个请用数组,0：向下拖动，1:向上拖动;
        startPullCall: function (type) { //开始滑动时触发回调
 
        },
        downEndCall: function (type) { //上拉超过边界或者下拉执行回调
 
        },
        upEndCall: function (type) { //上拉或者下拉,超出边界之后,恢复最初状态执行
 
 
 
            setTimeout(function () {
                appcan.window.resetBounceView(type);
                if (!type) {
 
                    //下拉刷新
                    //appcan.window.openToast("正在刷新,请稍等...", -1, 5, 1);
                    funcTop();
                } else {
 
                    //appcan.window.openToast("正在刷新,请稍等...", -1, 5, 1);
 
                    funcBottom();
                }
            }, 1000);
        },
        color: '#f0f0f0', // 如果超出了边界显示的背景颜色
        imgSettings: {
 
            // 如果超出了边界,并且想要设置 显示的内容包括图片文字则设置该参数
            'imagePath': 'res://shuaxin.png',
            'textColor': '#88c933',
            'pullToReloadText': '拖动刷新...',
            'releaseToReloadText': '释放刷新...',
            "loadingText": '加载中,请稍等...'
        }
 
    });
}
function onPullToRefresh() {
    //IC.talkingDataCount("部门通告","0010");
    curpage = 1;
    loadDataFromServer(0, 15, 0);
 
}
 
 
 
function onUpToLoadMore() {
    //IC.talkingDataCount("部门通告","0010");
    var cur = curpage++ * 15;
    loadDataFromServer(cur, 15, 1);
}
 
 
 
function loadDataFromServer(curpage, pagesize, type) {
 
 
    $.ajax({
        url: http + 'queryContents?',
        type: 'get',
        dataType: 'json',
        data: {
            folderId: folderId,
            curPage: curpage,
            pageSize: pagesize
        },
        success: function (res) {
 
            var data = JSON.parse(res.queryContents);
            var tpl = '';
            if (type == 0) {
                if (data.contents.length > 0) {
 
                    data.contents.forEach(function (item) {
                        tpl += '<li id="' + item.contentId +
                            '" class="bdr_b" onclick="detailPage(this)"><p class="fs10 pl5 tx-l h35 lh35 hide">' + item
                            .contentName + '</p></li>';
 
                    });
 
                    $('#context').html(tpl);
                } else {
 
                    $('#context').html('<div style="padding-top: 1em; text-align:center;">暂时没有据...</div>');
                    appcan.window.disableBounce();
                }
 
            } else {
 
                if (data.contents.length > 0) {
 
                    data.contents.forEach(function (item) {
                        tpl += '<li id="' + item.contentId +
                            '" class="bdr_b" onclick="detailPage(this)"><p class="fs10 pl5 tx-l h30 lh30 hide">' + item
                            .contentName + '</p></li>';
 
                    });
 
 
                    $('#context').append(tpl);
 
                } else {
 
 
 
                }
 
            }
 
 
            if (curpage >= data.count) {
                appcan.window.openToast("列表已经加载完毕", 2000, 5);
 
                return;
            }
 
        },
        error: function (err) {
 
            console.log(err);
        }
    });
  }           
           
            
            
    </script>
    
    
</html>
